﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:System="clr-namespace:System;assembly=mscorlib"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:v="clr-namespace:ClearMine.VM;assembly=ClearMine.VM"
                    xmlns:e="clr-namespace:ClearMine.Framework.Controls;assembly=ClearMine.Framework"
                    xmlns:b="clr-namespace:ClearMine.Framework.Behaviors;assembly=ClearMine.Framework"
                    xmlns:logic="clr-namespace:ClearMine.GameDefinition;assembly=ClearMine.GameDefinition"
                    xmlns:m="clr-namespace:ClearMine.GameDefinition;assembly=ClearMine.GameDefinition">
    <SolidColorBrush x:Key="DialogBackground" Color="#F0F0F0" />
    <PlaygroundBorderThicknessConverter x:Key="PlaygroundBorderThicknessConverter" />
    <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />

    <DataTemplate DataType="{x:Type logic:MineCell}">
        <MineCellControl />
    </DataTemplate>

    <DataTemplate DataType="{x:Type v:GameWonDetailsViewModel}">
        <AutoTransformPanel Margin="24,12,20,12">
            <StackPanel VerticalAlignment="Top">
                <StackPanel Orientation="Horizontal"
                            Margin="0,0,0,7">
                    <TextBlock Text="{DynamicResource GameWonBestTime}" />
                    <TextBlock Margin="0,0,20,0">
                    <Run Text="{Binding BestTime, StringFormat=0.00, Mode=OneWay}" />
                    <Run Text="{DynamicResource GameWonBestTimeSecond}" />
                    </TextBlock>
                    <TextBlock Text="{DynamicResource GameWonGamePlayed}" />
                    <TextBlock>
                    <Run Text="{Binding GameWon, Mode=OneWay}" />/<Run Text="{Binding GamePlayed, Mode=OneWay}" />
                    (<Run Text="{Binding WonRate, StringFormat= {}{0:P}, Mode=OneWay}" />)
                    </TextBlock>
                </StackPanel>
                <TextBlock TextAlignment="Right">
                    <Hyperlink Command="{x:Static m:GameCommands.ShowStatistics}">
                        <Run Text="{DynamicResource GameWonShowAllHistory}" />
                    </Hyperlink>
                </TextBlock>
            </StackPanel>
        </AutoTransformPanel>
    </DataTemplate>

    <ControlTemplate x:Key="ValidationErrorTemplate">
        <Border BorderBrush="#99FF0000"
                BorderThickness="1">
            <Border.Effect>
                <DropShadowEffect BlurRadius="4"
                                  Color="Red"
                                  ShadowDepth="0" />
            </Border.Effect>
            <AdornedElementPlaceholder />
        </Border>
    </ControlTemplate>

    <!--Common Colors definition-->
    <SolidColorBrush x:Key="FocusBorderBrush"
                     Color="#FF7DA2CE" />
    <SolidColorBrush x:Key="DarkSeparatorBrush"
                     Color="#FFA0A0A0" />
    <SolidColorBrush x:Key="LightSeparatorBrush"
                     Color="#FFCCCCCC" />

    <DrawingBrush x:Key="SeperatorBrush"
                  TileMode="Tile"
                  Viewport="0,0 1,2"
                  ViewportUnits="Absolute"
                  Stretch="None">
        <DrawingBrush.Drawing>
            <DrawingGroup>
                <GeometryDrawing Geometry="M0,0 L1,0 1,1 0,1Z"
                                 Brush="{DynamicResource {x:Static SystemColors.ControlDarkBrushKey}}" />
                <GeometryDrawing Geometry="M0,1 L1,1 1,2 0,2Z"
                                 Brush="White" />
            </DrawingGroup>
        </DrawingBrush.Drawing>
    </DrawingBrush>

    <DrawingBrush x:Key="DashFocusBrush"
                  TileMode="Tile"
                  Viewport="0,0 2,2"
                  ViewportUnits="Absolute"
                  Stretch="None">
        <DrawingBrush.Drawing>
            <GeometryDrawing Geometry="M0,0 L1,0 1,1 2,1 2,2 1,2 1,1 0,1Z"
                             Brush="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" />
        </DrawingBrush.Drawing>
    </DrawingBrush>

    <!--Item relative brushes-->
    <!--Mouse Over-->
    <SolidColorBrush x:Key="MouseOverItemBorderBrush"
                     Color="#FFB8D6FB" />
    <LinearGradientBrush x:Key="MouseOverItemInnerBorderBrush"
                         StartPoint="0,0"
                         EndPoint="0,1">
        <GradientStop Offset="0"
                      Color="#FFFCFDFE" />
        <GradientStop Offset="1"
                      Color="#FFF2F7FE" />
    </LinearGradientBrush>
    <LinearGradientBrush x:Key="MouseOverItemBackground"
                         StartPoint="0,0"
                         EndPoint="0,1">
        <GradientStop Offset="0"
                      Color="#FFFAFBFD" />
        <GradientStop Offset="1"
                      Color="#FFEBF3FD" />
    </LinearGradientBrush>
    <!--Selected-->
    <SolidColorBrush x:Key="SelectedItemBorderBrush"
                     Color="#FF84ACDD" />
    <LinearGradientBrush x:Key="SelectedItemInnerBorderBrush"
                         StartPoint="0,0"
                         EndPoint="0,1">
        <GradientStop Offset="0"
                      Color="#FFF1F7FE" />
        <GradientStop Offset="1"
                      Color="#FFDEEDFE" />
    </LinearGradientBrush>
    <LinearGradientBrush x:Key="SelectedItemBackground"
                         StartPoint="0,0"
                         EndPoint="0,1">
        <GradientStop Offset="0"
                      Color="#FFEBF4FE" />
        <GradientStop Offset="1"
                      Color="#FFCFE4FE" />
    </LinearGradientBrush>
    <!--Active-->
    <SolidColorBrush x:Key="ActiveItemBorderBrush"
                     Color="#FF7DA2EC" />
    <LinearGradientBrush x:Key="ActiveItemInnerBorderBrush"
                         StartPoint="0,0"
                         EndPoint="0,1">
        <GradientStop Offset="0"
                      Color="#FFEBF4FD" />
        <GradientStop Offset="1"
                      Color="#FFDBEAFD" />
    </LinearGradientBrush>
    <LinearGradientBrush x:Key="ActiveItemBackground"
                         StartPoint="0,0"
                         EndPoint="0,1">
        <GradientStop Offset="0"
                      Color="#FFDCEBFC" />
        <GradientStop Offset="1"
                      Color="#FFC1DBFC" />
    </LinearGradientBrush>
    <!--In active-->
    <SolidColorBrush x:Key="InactiveItemBorderBrush"
                     Color="#FFD9D9D9" />
    <LinearGradientBrush x:Key="InactiveItemInnerBorderBrush"
                         StartPoint="0,0"
                         EndPoint="0,1">
        <GradientStop Offset="0"
                      Color="#FFFAFAFB" />
        <GradientStop Offset="1"
                      Color="#FFF0F0F0" />
    </LinearGradientBrush>
    <LinearGradientBrush x:Key="InactiveItemBackground"
                         StartPoint="0,0"
                         EndPoint="0,1">
        <GradientStop Offset="0"
                      Color="#FFF8F8F8" />
        <GradientStop Offset="1"
                      Color="#FFE5E5E5" />
    </LinearGradientBrush>

    <Style x:Key="EmptyFocusVisual">
        <Setter Property="Control.Template">
            <Setter.Value>
                <ControlTemplate />
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="ButtonFocusVisual">
        <Setter Property="Control.Template">
            <Setter.Value>
                <ControlTemplate>
                    <Rectangle StrokeThickness="1"
                               Margin="2"
                               Stroke="{StaticResource DashFocusBrush}" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="ItemFocusVisual">
        <Setter Property="Control.Template">
            <Setter.Value>
                <ControlTemplate>
                    <Rectangle StrokeThickness="1"
                               Stroke="{StaticResource DashFocusBrush}" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type Button}">
        <Setter Property="Padding"
                Value="10,2" />
        <Setter Property="MinWidth"
                Value="75" />
        <Setter Property="VerticalAlignment"
                Value="Center" />
        <Setter Property="FocusVisualStyle"
                Value="{StaticResource ButtonFocusVisual}" />
    </Style>

    <Style x:Key="CheckBoxFocusVisual">
        <Setter Property="Control.Template">
            <Setter.Value>
                <ControlTemplate>
                    <Rectangle StrokeThickness="1"
                               Margin="14,0,-1,-1"
                               Stroke="{StaticResource DashFocusBrush}" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <Style TargetType="{x:Type CheckBox}">
        <Style.Triggers>
            <Trigger Property="HasContent"
                     Value="True">
                <Setter Property="FocusVisualStyle"
                        Value="{StaticResource CheckBoxFocusVisual}" />
            </Trigger>
        </Style.Triggers>
    </Style>

    <Style TargetType="{x:Type RadioButton}">
        <Style.Triggers>
            <Trigger Property="HasContent"
                     Value="True">
                <Setter Property="FocusVisualStyle"
                        Value="{StaticResource CheckBoxFocusVisual}" />
            </Trigger>
        </Style.Triggers>
    </Style>

    <Style TargetType="{x:Type Label}">
        <Setter Property="Padding"
                Value="0" />
        <Setter Property="VerticalAlignment"
                Value="Center" />
    </Style>

    <Style TargetType="{x:Type Separator}">
        <Setter Property="Background"
                Value="{StaticResource SeperatorBrush}" />
        <Setter Property="Margin"
                Value="0,2,0,2" />
        <Setter Property="Focusable"
                Value="false" />
        <Setter Property="Height"
                Value="2" />
        <Setter Property="UseLayoutRounding"
                Value="True" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Separator}">
                    <Border Background="{TemplateBinding Background}" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <Style TargetType="{x:Type Hyperlink}">
        <Setter Property="Foreground"
                Value="#FF0066CC" />
        <Setter Property="Background"
                Value="Transparent" />
        <Setter Property="TextDecorations"
                Value="{x:Null}" />
        <Setter Property="FocusVisualStyle"
                Value="{StaticResource ItemFocusVisual}" />
        <Style.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Foreground"
                        Value="#FF3399FF" />
                <Setter Property="TextDecorations"
                        Value="Underline" />
            </Trigger>
        </Style.Triggers>
    </Style>

    <Style x:Key="GeneratedMenuStyle" TargetType="{x:Type MenuItem}">
        <Setter Property="DataContext" Value="{Binding}" />
        <Setter Property="Header" Value="{Binding Header}"/>
        <Setter Property="Command" Value="{Binding Command}"/>
        <Setter Property="ItemsSource" Value="{Binding SubMenus}"/>
        <Setter Property="IsChecked" Value="{Binding IsChecked}" />
        <Setter Property="CommandParameter" Value="{Binding CommandParameter}"/>
        <Style.Triggers>
            <DataTrigger Binding="{Binding IsSeparator}" Value="True">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type MenuItem}">
                            <Separator Style="{DynamicResource {x:Static MenuItem.SeparatorStyleKey}}" />
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </DataTrigger>
        </Style.Triggers>
    </Style>

    <Style x:Key="{x:Static MenuItem.SeparatorStyleKey}"
           TargetType="{x:Type Separator}"
           BasedOn="{StaticResource {x:Type Separator}}">
        <Setter Property="Margin"
                Value="30,3,1,3" />
    </Style>

    <Style x:Key="SeparatorGroupBoxStyle"
           TargetType="{x:Type GroupBox}">
        <Setter Property="Padding"
                Value="18,5,7,12" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type GroupBox}">
                    <DockPanel>
                        <DockPanel DockPanel.Dock="Top">
                            <ContentPresenter ContentSource="Header"
                                              Margin="0,0,5,0"
                                              RecognizesAccessKey="True" />
                            <Separator Margin="0,2,0,0"
                                       HorizontalAlignment="Stretch"
                                       VerticalAlignment="Center" />
                        </DockPanel>
                        <ContentPresenter Margin="{TemplateBinding Padding}" />
                    </DockPanel>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type ListBoxItem}">
        <Setter Property="BorderBrush"
                Value="Transparent" />
        <Setter Property="Background"
                Value="Transparent" />
        <Setter Property="FocusVisualStyle"
                Value="{StaticResource ItemFocusVisual}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ListBoxItem}">
                    <Border BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="1">
                        <Border x:Name="InnerBorder"
                                BorderThickness="1"
                                Padding="3"
                                Background="{TemplateBinding Background}">
                            <ContentPresenter />
                        </Border>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver"
                                 Value="true">
                            <Setter Property="Background"
                                    Value="{StaticResource MouseOverItemBackground}" />
                            <Setter Property="BorderBrush"
                                    Value="{StaticResource MouseOverItemBorderBrush}" />
                            <Setter TargetName="InnerBorder"
                                    Property="BorderBrush"
                                    Value="{StaticResource MouseOverItemInnerBorderBrush}" />
                        </Trigger>
                        <Trigger Property="IsSelected"
                                 Value="true">
                            <Setter Property="Background"
                                    Value="{StaticResource SelectedItemBackground}" />
                            <Setter Property="BorderBrush"
                                    Value="{StaticResource SelectedItemBorderBrush}" />
                            <Setter TargetName="InnerBorder"
                                    Property="BorderBrush"
                                    Value="{StaticResource SelectedItemInnerBorderBrush}" />
                        </Trigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsSelected"
                                           Value="true" />
                                <Condition Property="Selector.IsSelectionActive"
                                           Value="false" />
                            </MultiTrigger.Conditions>
                            <Setter Property="Background"
                                    Value="{StaticResource InactiveItemBackground}" />
                            <Setter Property="BorderBrush"
                                    Value="{StaticResource InactiveItemBorderBrush}" />
                            <Setter TargetName="InnerBorder"
                                    Property="BorderBrush"
                                    Value="{StaticResource InactiveItemInnerBorderBrush}" />
                        </MultiTrigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsSelected"
                                           Value="true" />
                                <Condition Property="IsMouseOver"
                                           Value="true" />
                            </MultiTrigger.Conditions>
                            <Setter Property="Background"
                                    Value="{StaticResource ActiveItemBackground}" />
                            <Setter Property="BorderBrush"
                                    Value="{StaticResource ActiveItemBorderBrush}" />
                            <Setter TargetName="InnerBorder"
                                    Property="BorderBrush"
                                    Value="{StaticResource ActiveItemInnerBorderBrush}" />
                        </MultiTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="ListViewItemFocusVisual">
        <Setter Property="Control.Template">
            <Setter.Value>
                <ControlTemplate>
                    <Rectangle StrokeThickness="1"
                               RadiusX="2"
                               RadiusY="2"
                               Stroke="{StaticResource FocusBorderBrush}" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="{x:Static GridView.GridViewItemContainerStyleKey}"
           TargetType="{x:Type ListViewItem}">
        <Setter Property="FocusVisualStyle"
                Value="{StaticResource ListViewItemFocusVisual}" />
        <Setter Property="Background"
                Value="Transparent" />
        <Setter Property="BorderBrush"
                Value="Transparent" />
        <Setter Property="BorderThickness"
                Value="1" />
        <Setter Property="Margin"
                Value="0,0,0,1" />
        <Setter Property="Padding"
                Value="5,2,5,2" />
        <Setter Property="VerticalContentAlignment"
                Value="Center" />
        <Setter Property="HorizontalContentAlignment"
                Value="Stretch" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ListViewItem}">
                    <Border BorderThickness="{TemplateBinding BorderThickness}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            Background="{TemplateBinding Background}"
                            CornerRadius="2"
                            SnapsToDevicePixels="true">
                        <Border Name="InnerBorder"
                                CornerRadius="1"
                                BorderThickness="1">
                            <GridViewRowPresenter Grid.RowSpan="2"
                                                  VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                                  SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                        </Border>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver"
                                 Value="true">
                            <Setter Property="Background"
                                    Value="{StaticResource MouseOverItemBackground}" />
                            <Setter Property="BorderBrush"
                                    Value="{StaticResource MouseOverItemBorderBrush}" />
                            <Setter TargetName="InnerBorder"
                                    Property="BorderBrush"
                                    Value="{StaticResource MouseOverItemInnerBorderBrush}" />
                        </Trigger>
                        <Trigger Property="IsSelected"
                                 Value="true">
                            <Setter Property="Background"
                                    Value="{StaticResource SelectedItemBackground}" />
                            <Setter Property="BorderBrush"
                                    Value="{StaticResource SelectedItemBorderBrush}" />
                            <Setter TargetName="InnerBorder"
                                    Property="BorderBrush"
                                    Value="{StaticResource SelectedItemInnerBorderBrush}" />
                        </Trigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsSelected"
                                           Value="true" />
                                <Condition Property="Selector.IsSelectionActive"
                                           Value="false" />
                            </MultiTrigger.Conditions>
                            <Setter Property="Background"
                                    Value="{StaticResource InactiveItemBackground}" />
                            <Setter Property="BorderBrush"
                                    Value="{StaticResource InactiveItemBorderBrush}" />
                            <Setter TargetName="InnerBorder"
                                    Property="BorderBrush"
                                    Value="{StaticResource InactiveItemInnerBorderBrush}" />
                        </MultiTrigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsSelected"
                                           Value="true" />
                                <Condition Property="IsMouseOver"
                                           Value="true" />
                            </MultiTrigger.Conditions>
                            <Setter Property="Background"
                                    Value="{StaticResource ActiveItemBackground}" />
                            <Setter Property="BorderBrush"
                                    Value="{StaticResource ActiveItemBorderBrush}" />
                            <Setter TargetName="InnerBorder"
                                    Property="BorderBrush"
                                    Value="{StaticResource ActiveItemInnerBorderBrush}" />
                        </MultiTrigger>
                        <Trigger Property="IsEnabled"
                                 Value="false">
                            <Setter Property="Foreground"
                                    Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type ListView}">
        <Setter Property="b:SortableListViewBehavior.HeaderSort"
                Value="True" />
        <Setter Property="ItemContainerStyle"
                Value="{StaticResource {x:Static GridView.GridViewItemContainerStyleKey}}" />
    </Style>

    <System:Double x:Key="ResizeThumbSize">4</System:Double>

    <Style x:Key="WindowResizeThumbStyle" TargetType="{x:Type Thumb}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate>
                    <Border Background="Transparent"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="e:ThumbExt.ResizeTarget" Value="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}"/>
    </Style>

    <Style x:Key="ResizableWindowBorderStyle" TargetType="{x:Type ContentControl}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ContentControl}">
                    <Grid>
                        <ContentPresenter Content="{TemplateBinding Content}"/>
                        <Grid Margin="1">
                            <Thumb Style="{StaticResource WindowResizeThumbStyle}" e:ThumbExt.ResizeMode="VerticalUp" HorizontalAlignment="Stretch" VerticalAlignment="Top" Height="{StaticResource ResizeThumbSize}" Cursor="SizeNS"/>
                            <Thumb Style="{StaticResource WindowResizeThumbStyle}" e:ThumbExt.ResizeMode="VerticalDown" HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Height="{StaticResource ResizeThumbSize}" Cursor="SizeNS"/>
                            <Thumb Style="{StaticResource WindowResizeThumbStyle}" e:ThumbExt.ResizeMode="HorizontalLeft" HorizontalAlignment="Left" VerticalAlignment="Stretch" Width="{StaticResource ResizeThumbSize}" Cursor="SizeWE"/>
                            <Thumb Style="{StaticResource WindowResizeThumbStyle}" e:ThumbExt.ResizeMode="HorizontalRight" HorizontalAlignment="Right" VerticalAlignment="Stretch" Width="{StaticResource ResizeThumbSize}" Cursor="SizeWE"/>
                            <Thumb Style="{StaticResource WindowResizeThumbStyle}" e:ThumbExt.ResizeMode="RightUp" HorizontalAlignment="Right" VerticalAlignment="Top" Width="{StaticResource ResizeThumbSize}" Height="{StaticResource ResizeThumbSize}" Cursor="SizeNESW"/>
                            <Thumb Style="{StaticResource WindowResizeThumbStyle}" e:ThumbExt.ResizeMode="LeftDown" HorizontalAlignment="Left" VerticalAlignment="Bottom" Width="{StaticResource ResizeThumbSize}" Height="{StaticResource ResizeThumbSize}" Cursor="SizeNESW"/>
                            <Thumb Style="{StaticResource WindowResizeThumbStyle}" e:ThumbExt.ResizeMode="LeftUp" HorizontalAlignment="Left" VerticalAlignment="Top" Width="{StaticResource ResizeThumbSize}" Height="{StaticResource ResizeThumbSize}" Cursor="SizeNWSE"/>
                            <Thumb Style="{StaticResource WindowResizeThumbStyle}" e:ThumbExt.ResizeMode="RightDown" HorizontalAlignment="Right" VerticalAlignment="Bottom" Width="{StaticResource ResizeThumbSize}" Height="{StaticResource ResizeThumbSize}" Cursor="SizeNWSE"/>
                        </Grid>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type Window}">
        <Setter Property="UseLayoutRounding" Value="True" />
        <Setter Property="TextOptions.TextFormattingMode" Value="Display" />
        <Setter Property="Content" Value="{Binding}" />
        <Setter Property="Width" Value="{Binding Width, Mode=TwoWay}" />
        <Setter Property="ResizeMode" Value="CanResize" />
        <Setter Property="Title" Value="{DynamicResource ApplicationTitle}" />
    </Style>
</ResourceDictionary>